<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>基本列表</title>
    <script src="../../../public/vue.js"></script>
</head>
<body>
<div id="app">
    <ul>
        <li v-for="(item, list) in list" :key="item.id">
            {{ item.name }}:{{ item.age }}
        </li>
        <input type="text" v-model="fileter">

        <li v-for="(item) in filterList" :key="item.id">
            {{ item.name }}:{{ item.age }}
        </li>
    </ul>
</div>
</body>
<script type="text/javascript">
    const vm = new Vue({
        el: '#app',
        data: {
            list: [
                {
                    id: 1,
                    name: '张三',
                    age: 18,
                    sex: '男'
                },
                {
                    id: 2,
                    name: '李四',
                    age: 19,
                    sex: '女'
                },
                {
                    id: 3,
                    name: '王五',
                    age: 20,
                    sex: '男'
                }
            ],
            fileter: '',
        },
        computed: {
            filterList() {
                return this.list.filter(item => item.name.indexOf(this.fileter) !== -1)
            }
        }
    })
</script>
</html>